package com.charlotte.study.gupao.interpreter.calculate.v1;

/**
 * @author junjie.ding
 * @date 2020/3/24
 */
public class OperatorUtil {

    public static boolean isOperator(String symbol){
        return symbol.equals("+") || symbol.equals("-") || symbol.equals("*") || symbol.equals("/");
    }

    public static boolean isHighOperator(String symbol){
        return symbol.equals("*") || symbol.equals("/");
    }

    public static boolean isLowOperator(String symbol){
        return symbol.equals("+") || symbol.equals("-");
    }

    public static Interpreter getInterpreter(IArithmeticInterpreter left, IArithmeticInterpreter right, String symbol){
        if(symbol.equals("+")){
            return new AddInterpreter(left, right);
        }else if(symbol.equals("-")){
            return new SubInterpreter(left, right);
        }else if(symbol.equals("*")){
            return new MultiInterpreter(left, right);
        }else if(symbol.equals("/")){
            return new DivInterpreter(left, right);
        }
        return null;
    }
}
